package com.jbob.app;

import java.awt.Color;
import java.awt.ComponentOrientation;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.HeadlessException;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.WindowConstants;
import javax.swing.JTextField;

import weka.classifiers.Classifier;
import weka.classifiers.Evaluation;
import weka.classifiers.bayes.NaiveBayes;
import weka.classifiers.trees.J48;
import weka.core.Instance;
import weka.core.Instances;

import com.jbob.utils.Utils;

public class MainWindow extends JFrame implements ActionListener
{
	private static final long serialVersionUID = 8716542766013718490L;
	private JPanel jContentPane = null;
	private JLabel jLabel0 = null;
	private JLabel jLabel1 = null;
	private JLabel jLabel2 = null;
	private JLabel jLabel3 = null;
	private JLabel jLabel4 = null;
	private JLabel jLabel5 = null;
	private JLabel jLabel6 = null;
	private JLabel jLabel7 = null;
	private JLabel jLabel8 = null;
	private JLabel jLabel9 = null;
	private JLabel jLabel10 = null;
	private JLabel jLabel11 = null;
	private JLabel jLabel12 = null;
	private JLabel jLabel13 = null;
	private JButton mValidate = null;
	private JComboBox mCheckingStatus = null;
	private JComboBox mCreditHistory = null;
	private JComboBox mPurpose = null;
	private JComboBox mSavingStatus = null;
	private JComboBox mEmployment = null;
	private JComboBox mPersonalStatus = null;
	private JComboBox mOtherParties = null;
	private JComboBox mPropertyMagnitude = null;
	private JComboBox mOtherPaymentPlans = null;
	private JComboBox mHousing= null;
	private JComboBox mJob = null;
	private JComboBox mOwnTelephone = null;
	private JComboBox mForeignWorker = null;
	private JComboBox mClass= null;
	private JLabel jLabelempty = null;
	private JTextField m_dureeEmprunt = null;

	public JPanel getjContentPane() {
		return jContentPane;
	}

	public void setjContentPane(JPanel jContentPane) {
		this.jContentPane = jContentPane;
	}

	public JLabel getjLabel0() {
		return jLabel0;
	}

	public void setjLabel0(JLabel jLabel0) {
		this.jLabel0 = jLabel0;
	}

	public JLabel getjLabel1() {
		return jLabel1;
	}

	public void setjLabel1(JLabel jLabel1) {
		this.jLabel1 = jLabel1;
	}

	public JLabel getjLabel2() {
		return jLabel2;
	}

	public void setjLabel2(JLabel jLabel2) {
		this.jLabel2 = jLabel2;
	}

	public JLabel getjLabel3() {
		return jLabel3;
	}

	public void setjLabel3(JLabel jLabel3) {
		this.jLabel3 = jLabel3;
	}

	public JLabel getjLabel4() {
		return jLabel4;
	}

	public void setjLabel4(JLabel jLabel4) {
		this.jLabel4 = jLabel4;
	}

	public JLabel getjLabel5() {
		return jLabel5;
	}

	public void setjLabel5(JLabel jLabel5) {
		this.jLabel5 = jLabel5;
	}

	public JLabel getjLabel6() {
		return jLabel6;
	}

	public void setjLabel6(JLabel jLabel6) {
		this.jLabel6 = jLabel6;
	}

	public JLabel getjLabel7() {
		return jLabel7;
	}

	public void setjLabel7(JLabel jLabel7) {
		this.jLabel7 = jLabel7;
	}

	public JLabel getjLabel8() {
		return jLabel8;
	}

	public void setjLabel8(JLabel jLabel8) {
		this.jLabel8 = jLabel8;
	}

	public JLabel getjLabel9() {
		return jLabel9;
	}

	public void setjLabel9(JLabel jLabel9) {
		this.jLabel9 = jLabel9;
	}
	
	public JLabel getjLabel10() {
		return jLabel10;
	}
	
	public JLabel getjLabel11() {
		return jLabel11;
	}
	
	public JLabel getjLabel12() {
		return jLabel12;
	}
	
	public JLabel getjLabel13() {
		return jLabel13;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	/**
	 * @throws HeadlessException
	 */
	public MainWindow() throws HeadlessException {
		super();
		initialize();
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		this.setSize(674, 376);
		this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
		this.setContentPane(getJContentPane());
		this.setTitle("JFrame");
		this.setVisible(true);
	}

	/**
	 * This method initializes jContentPane
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getJContentPane() {
		if (jContentPane == null) {
			GridBagConstraints gridBagConstraints28 = new GridBagConstraints();
			gridBagConstraints28.gridx = 2;
			gridBagConstraints28.weightx = 1.0;
			gridBagConstraints28.gridy = 14;
			gridBagConstraints28.fill = GridBagConstraints.VERTICAL;
			GridBagConstraints gridBagConstraints27 = new GridBagConstraints();
			gridBagConstraints27.gridx = 2;
			gridBagConstraints27.weightx = 1.0;
			gridBagConstraints27.gridy = 13;
			gridBagConstraints27.fill = GridBagConstraints.VERTICAL;
			GridBagConstraints gridBagConstraints26 = new GridBagConstraints();
			gridBagConstraints26.gridx = 2;
			gridBagConstraints26.weightx = 1.0;
			gridBagConstraints26.gridy = 12;
			gridBagConstraints26.fill = GridBagConstraints.VERTICAL;
			GridBagConstraints gridBagConstraints25 = new GridBagConstraints();
			gridBagConstraints25.gridx = 2;
			gridBagConstraints25.weightx = 1.0;
			gridBagConstraints25.gridy = 11;
			gridBagConstraints25.fill = GridBagConstraints.VERTICAL;
			GridBagConstraints gridBagConstraints24 = new GridBagConstraints();
			gridBagConstraints24.gridx = 2;
			gridBagConstraints24.weightx = 1.0;
			gridBagConstraints24.gridy = 10;
			gridBagConstraints24.fill = GridBagConstraints.VERTICAL;
			GridBagConstraints gridBagConstraints23 = new GridBagConstraints();
			gridBagConstraints23.gridx = 2;
			gridBagConstraints23.weightx = 1.0;
			gridBagConstraints23.gridy = 9;
			gridBagConstraints23.fill = GridBagConstraints.VERTICAL;
			jLabelempty = new JLabel();
			jLabelempty.setText("   ");
			GridBagConstraints gridBagConstraints22 = new GridBagConstraints();
			gridBagConstraints22.fill = GridBagConstraints.VERTICAL;
			gridBagConstraints22.gridy = 8;
			gridBagConstraints22.weightx = 1.0;
			gridBagConstraints22.gridx = 2;
			GridBagConstraints gridBagConstraints21 = new GridBagConstraints();
			gridBagConstraints21.fill = GridBagConstraints.VERTICAL;
			gridBagConstraints21.gridy = 7;
			gridBagConstraints21.weightx = 1.0;
			gridBagConstraints21.gridx = 2;
			GridBagConstraints gridBagConstraints20 = new GridBagConstraints();
			gridBagConstraints20.fill = GridBagConstraints.VERTICAL;
			gridBagConstraints20.gridy = 6;
			gridBagConstraints20.weightx = 1.0;
			gridBagConstraints20.gridx = 2;
			GridBagConstraints gridBagConstraints19 = new GridBagConstraints();
			gridBagConstraints19.fill = GridBagConstraints.VERTICAL;
			gridBagConstraints19.gridy = 5;
			gridBagConstraints19.weightx = 1.0;
			gridBagConstraints19.gridx = 2;
			GridBagConstraints gridBagConstraints18 = new GridBagConstraints();
			gridBagConstraints18.fill = GridBagConstraints.VERTICAL;
			gridBagConstraints18.gridy = 4;
			gridBagConstraints18.weightx = 1.0;
			gridBagConstraints18.gridx = 2;
			GridBagConstraints gridBagConstraints17 = new GridBagConstraints();
			gridBagConstraints17.fill = GridBagConstraints.VERTICAL;
			gridBagConstraints17.gridy = 3;
			gridBagConstraints17.weightx = 1.0;
			gridBagConstraints17.gridx = 2;
			GridBagConstraints gridBagConstraints16 = new GridBagConstraints();
			gridBagConstraints16.fill = GridBagConstraints.VERTICAL;
			gridBagConstraints16.gridy = 2;
			gridBagConstraints16.weightx = 1.0;
			gridBagConstraints16.gridx = 2;
			GridBagConstraints gridBagConstraints15 = new GridBagConstraints();
			gridBagConstraints15.fill = GridBagConstraints.VERTICAL;
			gridBagConstraints15.gridy = 1;
			gridBagConstraints15.weightx = 1.0;
			gridBagConstraints15.gridx = 2;
			GridBagConstraints gridBagConstraints14 = new GridBagConstraints();
			gridBagConstraints14.fill = GridBagConstraints.VERTICAL;
			gridBagConstraints14.gridy = 0;
			gridBagConstraints14.weightx = 1.0;
			gridBagConstraints14.gridx = 2;
			jLabel13 = new JLabel();
			jLabel13.setText("Classe");
			jLabel13.setHorizontalAlignment(SwingConstants.RIGHT);
			GridBagConstraints gridBagConstraints13 = new GridBagConstraints();
			gridBagConstraints13.gridx = 0;
			gridBagConstraints13.anchor = GridBagConstraints.EAST;
			gridBagConstraints13.gridy = 13;
			jLabel12 = new JLabel();
			jLabel12.setText("Travailleur etranger");
			jLabel12.setHorizontalAlignment(SwingConstants.RIGHT);
			GridBagConstraints gridBagConstraints12 = new GridBagConstraints();
			gridBagConstraints12.gridx = 0;
			gridBagConstraints12.anchor = GridBagConstraints.EAST;
			gridBagConstraints12.gridy = 12;
			jLabel11 = new JLabel();
			jLabel11.setText("Telephone");
			jLabel11.setHorizontalAlignment(SwingConstants.RIGHT);
			GridBagConstraints gridBagConstraints11 = new GridBagConstraints();
			gridBagConstraints11.gridx = 0;
			gridBagConstraints11.anchor = GridBagConstraints.EAST;
			gridBagConstraints11.gridy = 11;
			jLabel10 = new JLabel();
			jLabel10.setText("Travail");
			jLabel10.setHorizontalAlignment(SwingConstants.RIGHT);
			GridBagConstraints gridBagConstraints10 = new GridBagConstraints();
			gridBagConstraints10.gridx = 0;
			gridBagConstraints10.anchor = GridBagConstraints.EAST;
			gridBagConstraints10.gridy = 10;
			jLabel9 = new JLabel();
			jLabel9.setText("Logement");
			jLabel9.setHorizontalAlignment(SwingConstants.RIGHT);
			GridBagConstraints gridBagConstraints9 = new GridBagConstraints();
			gridBagConstraints9.gridx = 0;
			gridBagConstraints9.anchor = GridBagConstraints.EAST;
			gridBagConstraints9.gridy = 9;
			jLabel8 = new JLabel();
			jLabel8.setText("Autres prets");
			jLabel8.setHorizontalAlignment(SwingConstants.RIGHT);
			GridBagConstraints gridBagConstraints8 = new GridBagConstraints();
			gridBagConstraints8.gridx = 0;
			gridBagConstraints8.anchor = GridBagConstraints.EAST;
			gridBagConstraints8.gridy = 8;
			jLabel7 = new JLabel();
			jLabel7.setText("Property magnitude");
			jLabel7.setHorizontalAlignment(SwingConstants.RIGHT);
			GridBagConstraints gridBagConstraints7 = new GridBagConstraints();
			gridBagConstraints7.gridx = 0;
			gridBagConstraints7.anchor = GridBagConstraints.EAST;
			gridBagConstraints7.gridy = 7;
			jLabel6 = new JLabel();
			jLabel6.setText("Autres parties");
			jLabel6.setHorizontalAlignment(SwingConstants.RIGHT);
			GridBagConstraints gridBagConstraints6 = new GridBagConstraints();
			gridBagConstraints6.gridx = 0;
			gridBagConstraints6.anchor = GridBagConstraints.EAST;
			gridBagConstraints6.gridy = 6;
			jLabel5 = new JLabel();
			jLabel5.setText("Status personnel");
			jLabel5.setHorizontalAlignment(SwingConstants.RIGHT);
			GridBagConstraints gridBagConstraints5 = new GridBagConstraints();
			gridBagConstraints5.gridx = 0;
			gridBagConstraints5.anchor = GridBagConstraints.EAST;
			gridBagConstraints5.gridy = 5;
			jLabel4 = new JLabel();
			jLabel4.setText("Emploi");
			jLabel4.setHorizontalAlignment(SwingConstants.RIGHT);
			GridBagConstraints gridBagConstraints4 = new GridBagConstraints();
			gridBagConstraints4.gridx = 0;
			gridBagConstraints4.anchor = GridBagConstraints.EAST;
			gridBagConstraints4.gridy = 4;
			jLabel3 = new JLabel();
			jLabel3.setText("Status epargne");
			jLabel3.setHorizontalAlignment(SwingConstants.RIGHT);
			GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
			gridBagConstraints3.gridx = 0;
			gridBagConstraints3.anchor = GridBagConstraints.EAST;
			gridBagConstraints3.gridy = 3;
			jLabel2 = new JLabel();
			jLabel2.setText("Raison");
			jLabel2.setHorizontalAlignment(SwingConstants.RIGHT);
			GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
			gridBagConstraints2.gridx = 0;
			gridBagConstraints2.anchor = GridBagConstraints.EAST;
			gridBagConstraints2.gridy = 2;
			jLabel1 = new JLabel();
			jLabel1.setText("Historique");
			jLabel1.setHorizontalAlignment(SwingConstants.RIGHT);
			GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
			gridBagConstraints1.gridx = 0;
			gridBagConstraints1.anchor = GridBagConstraints.EAST;
			gridBagConstraints1.gridy = 1;
			jLabel0 = new JLabel();
			jLabel0.setText("Status cheques");
			jLabel0.setHorizontalAlignment(SwingConstants.RIGHT);
			GridBagConstraints gridBagConstraints = new GridBagConstraints();
			gridBagConstraints.gridx = 0;
			gridBagConstraints.anchor = GridBagConstraints.EAST;
			gridBagConstraints.gridy = 0;
			
			jContentPane = new JPanel();
			jContentPane.setLayout(new GridBagLayout());
			jContentPane.add(jLabel0, gridBagConstraints);
			jContentPane.add(jLabel1, gridBagConstraints1);
			jContentPane.add(jLabel2, gridBagConstraints2);
			jContentPane.add(jLabel3, gridBagConstraints3);
			jContentPane.add(jLabel4, gridBagConstraints4);
			jContentPane.add(jLabel5, gridBagConstraints5);
			jContentPane.add(jLabel6, gridBagConstraints6);
			jContentPane.add(jLabel7, gridBagConstraints7);
			jContentPane.add(jLabel8, gridBagConstraints8);
			jContentPane.add(jLabel9, gridBagConstraints9);
			jContentPane.add(jLabel10, gridBagConstraints10);
			jContentPane.add(jLabel11, gridBagConstraints11);
			jContentPane.add(jLabel12, gridBagConstraints12);
			jContentPane.add(jLabel13, gridBagConstraints13);
			jContentPane.add(getCheckingStatus(), gridBagConstraints14);
			jContentPane.add(getCreditHistory(), gridBagConstraints15);
			jContentPane.add(getPurpose(), gridBagConstraints16);
			jContentPane.add(getSavingStatus(), gridBagConstraints17);
			jContentPane.add(getEmployment(), gridBagConstraints18);
			jContentPane.add(getPersonalStatus(), gridBagConstraints19);
			jContentPane.add(getOtherParties(), gridBagConstraints20);
			jContentPane.add(getPropertyMagnitude(), gridBagConstraints21);
			jContentPane.add(getOtherPaymentPlans(), gridBagConstraints22);
			jContentPane.add(getHousing(), gridBagConstraints23);
			jContentPane.add(getJob(), gridBagConstraints24);
			jContentPane.add(getOwnTelephone(), gridBagConstraints25);
			jContentPane.add(getForeignWorker(), gridBagConstraints26);
			jContentPane.add(getClasss(), gridBagConstraints27);
			jContentPane.add(getValidateButton(), gridBagConstraints28);
		}
		return jContentPane;
	}

	public JLabel getjLabelempty() {
		return jLabelempty;
	}

	public void setjLabelempty(JLabel jLabelempty) {
		this.jLabelempty = jLabelempty;
	}

	private JButton getValidateButton() {
		if (mValidate == null) {
			mValidate = new JButton();
			mValidate.setText("Valider");
			mValidate.setActionCommand("Valider");
			mValidate.addActionListener(this);
		}
		return mValidate;
	}
	
	public JComboBox getCheckingStatus()
	{
		if(mCheckingStatus == null)
		{
			mCheckingStatus = new JComboBox();
			mCheckingStatus.addItem("<0");
			mCheckingStatus.addItem("0<=X<200");
			mCheckingStatus.addItem(">=200");
			mCheckingStatus.addItem("no checking");
			mCheckingStatus.setPreferredSize(new Dimension(200, mCheckingStatus.getHeight()));
		}
		return mCheckingStatus;
	}
	
	public JComboBox getCreditHistory()
	{
		if(mCreditHistory == null)
		{
			mCreditHistory = new JComboBox();
			mCreditHistory.addItem("no credits/all paid");
			mCreditHistory.addItem("all paid");
			mCreditHistory.addItem("existing paid");
			mCreditHistory.addItem("delayed previously");
			mCreditHistory.addItem("critical/other existing credit");
			mCreditHistory.setPreferredSize(new Dimension(200, mCreditHistory.getHeight()));
		}
		return mCreditHistory;
	}
	
	public JComboBox getPurpose()
	{
		if(mPurpose == null)
		{
			mPurpose = new JComboBox();
			mPurpose.addItem("new car");
			mPurpose.addItem("used car");
			mPurpose.addItem("furniture/equipment");
			mPurpose.addItem("radio/tv");
			mPurpose.addItem("domestic appliance");
			mPurpose.addItem("repairs");
			mPurpose.addItem("education");
			mPurpose.addItem("vacation");
			mPurpose.addItem("retraining");
			mPurpose.addItem("business");
			mPurpose.addItem("other");
			mPurpose.setPreferredSize(new Dimension(200, mPurpose.getHeight()));
		}
		return mPurpose;
	}
	
	public JComboBox getSavingStatus()
	{
		if(mSavingStatus == null)
		{
			mSavingStatus = new JComboBox();
			mSavingStatus.addItem("<100");
			mSavingStatus.addItem("100<=X<500");
			mSavingStatus.addItem("500<=X<1000");
			mSavingStatus.addItem(">=1000");
			mSavingStatus.addItem("no known savings");
			mSavingStatus.setPreferredSize(new Dimension(200, mSavingStatus.getHeight()));
		}
		return mSavingStatus;
	}
	
	public JComboBox getEmployment()
	{
		if(mEmployment == null)
		{
			mEmployment = new JComboBox();
			mEmployment.addItem("unemployed");
			mEmployment.addItem("<1");
			mEmployment.addItem("1<=X<4");
			mEmployment.addItem("4<=X<7");
			mEmployment.addItem(">=7");
			mEmployment.setPreferredSize(new Dimension(200, mEmployment.getHeight()));
		}
		return mEmployment;
	}
	
	public JComboBox getPersonalStatus()
	{
		if(mPersonalStatus == null)
		{
			mPersonalStatus = new JComboBox();
			mPersonalStatus.addItem("male div/sep");
			mPersonalStatus.addItem("female div/dep/mar");
			mPersonalStatus.addItem("male single");
			mPersonalStatus.addItem("male mar/wid");
			mPersonalStatus.addItem("female single");
			mPersonalStatus.setPreferredSize(new Dimension(200, mPersonalStatus.getHeight()));
		}
		return mPersonalStatus;
	}
	
	public JComboBox getOtherParties()
	{
		if(mOtherParties == null)
		{
			mOtherParties = new JComboBox();
			mOtherParties.addItem("none");
			mOtherParties.addItem("co applicant");
			mOtherParties.addItem("guarantor");
			mOtherParties.setPreferredSize(new Dimension(200, mOtherParties.getHeight()));
		}
		return mOtherParties;
	}
	
	public JComboBox getPropertyMagnitude()
	{
		if(mPropertyMagnitude == null)
		{
			mPropertyMagnitude = new JComboBox();
			mPropertyMagnitude.addItem("real estate");
			mPropertyMagnitude.addItem("life insurance");
			mPropertyMagnitude.addItem("car");
			mPropertyMagnitude.addItem("no known property");
			mPropertyMagnitude.setPreferredSize(new Dimension(200, mPropertyMagnitude.getHeight()));
		}
		return mPropertyMagnitude;
	}
	
	public JComboBox getOtherPaymentPlans()
	{
		if(mOtherPaymentPlans == null)
		{
			mOtherPaymentPlans = new JComboBox();
			mOtherPaymentPlans.addItem("bank");
			mOtherPaymentPlans.addItem("stores");
			mOtherPaymentPlans.addItem("none");
			mOtherPaymentPlans.setPreferredSize(new Dimension(200, mOtherPaymentPlans.getHeight()));
		}
		return mOtherPaymentPlans;
	}
	
	public JComboBox getHousing()
	{
		if(mHousing == null)
		{
			mHousing = new JComboBox();
			mHousing.addItem("rent");
			mHousing.addItem("own");
			mHousing.addItem("for free");
			mHousing.setPreferredSize(new Dimension(200, mHousing.getHeight()));
		}
		return mHousing;
	}
	
	public JComboBox getJob()
	{
		if(mJob == null)
		{
			mJob = new JComboBox();
			mJob.addItem("unemp/unskilled non res");
			mJob.addItem("unskilled resident");
			mJob.addItem("skilled");
			mJob.addItem("high qualif/self emp/mgmt");
			mJob.setPreferredSize(new Dimension(200, mJob.getHeight()));
		}
		return mJob;
	}
	
	public JComboBox getOwnTelephone()
	{
		if(mOwnTelephone == null)
		{
			mOwnTelephone = new JComboBox();
			mOwnTelephone.addItem("none");
			mOwnTelephone.addItem("yes");
			mOwnTelephone.setPreferredSize(new Dimension(200, mOwnTelephone.getHeight()));
		}
		return mOwnTelephone;
	}
	
	public JComboBox getForeignWorker()
	{
		if(mForeignWorker == null)
		{
			mForeignWorker = new JComboBox();
			mForeignWorker.addItem("yes");
			mForeignWorker.addItem("no");
			mForeignWorker.setPreferredSize(new Dimension(200, mForeignWorker.getHeight()));
		}
		return mForeignWorker;
	}
	
	public JComboBox getClasss()
	{
		if(mClass == null)
		{
			mClass = new JComboBox();
			mClass.addItem("good");
			mClass.addItem("bad");
			mClass.setPreferredSize(new Dimension(200, mClass.getHeight()));
		}
		return mClass;
	}

	/**
	 * This method initializes m_dureeEmprunt	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	public JTextField getM_dureeEmprunt() {
		if (m_dureeEmprunt == null) {
			m_dureeEmprunt = new JTextField();
			m_dureeEmprunt.setPreferredSize(new Dimension(200, 20));
		}
		return m_dureeEmprunt;
	}

	@Override
	public void actionPerformed(ActionEvent e) 
	{
		Instances data = null;
		try {
			data = main.getDataSource().getDataSet();

			if (data.classIndex() == -1)
				data.setClassIndex(data.numAttributes() - 1);
	
			// Delete all type numeric
			data.deleteAttributeType(0);
	
			System.out.println(data.toSummaryString());
	
			// S�paration du jeu de donn�es en 2 instances
			Instances isTrainingSet = new Instances(data, 0, 666);
			Instances isTestSet = new Instances(data, 666, main.NB_INSTANCE_TEST);
			
			
			 // construction de l'instance
			Object[] data1 = new String[14];
			data1[0] = getCheckingStatus().getSelectedItem();
			data1[1] = getCreditHistory().getSelectedItem();
			data1[2] = getPurpose().getSelectedItem();
			data1[3] = getSavingStatus().getSelectedItem();
			data1[4] = getEmployment().getSelectedItem();
			data1[5] = getPersonalStatus().getSelectedItem();
			data1[6] = getOtherParties().getSelectedItem();
			data1[7] = getPropertyMagnitude().getSelectedItem();
			data1[8] = getOtherPaymentPlans().getSelectedItem();
			data1[9] = getHousing().getSelectedItem();
			data1[10] = getJob().getSelectedItem();
			data1[11] = getOwnTelephone().getSelectedItem();
			data1[12] = getForeignWorker().getSelectedItem();
			data1[13] = getClasss().getSelectedItem();
	
	
			// *************************************
			// NAIVES BAYES
			// *************************************
			
	//		ModelEvaluator modelEvaluator = new ModelEvaluator(new J48());
			
	//		double precision;
	//		precision = modelEvaluator.getPrecisionModel(data);
	//		System.out.println("Pr�cision : " + precision);
			
			System.out.println(" --- NAIVES BAYES --- ");
			
			Classifier cModel = (Classifier) new NaiveBayes();
			cModel.buildClassifier(isTrainingSet);
	
			// Test the model
			Evaluation eTest = new Evaluation(isTestSet);
	
			eTest.evaluateModel(cModel, isTestSet);
	
			double precision = (main.NB_INSTANCE_TEST - eTest.incorrect())
					/ main.NB_INSTANCE_TEST;
	
			System.out.println("calcul pr�cision : (" + main.NB_INSTANCE_TEST + " - " + eTest.incorrect() + ") / " + main.NB_INSTANCE_TEST );
			System.out.println("Pr�cision calcul�e : " + precision);
			
					
			Instance instance = Utils.createInstance(data1, isTestSet);
			
			double[] probaBAYESIEN = cModel.distributionForInstance(instance);
			
			for (double d : probaBAYESIEN) {
				System.out.print(d + " - ");
			}
			
			// *************************************
			// J48
			// *************************************
	
			System.out.println(" --- J48 --- ");
			
			Classifier cModelJ48 = (Classifier) new J48();
			cModelJ48.buildClassifier(isTrainingSet);
	
			// Test the model
			Evaluation eTestJ48 = new Evaluation(isTestSet);
	
			eTestJ48.evaluateModel(cModelJ48, isTestSet);
	
			double precisionJ48 = (main.NB_INSTANCE_TEST - eTestJ48.incorrect())
					/ main.NB_INSTANCE_TEST;
	
			System.out.println("calcul pr�cision : (" + main.NB_INSTANCE_TEST + " - " + eTestJ48.incorrect() + ") / " + main.NB_INSTANCE_TEST );
			System.out.println("Pr�cision calcul�e : " + precisionJ48);
			
	
			
			Instance instanceJ48 = Utils.createInstance(data1, isTestSet);
			System.out.println("INSTANCE : ");
			System.out.println("------------------------");
			System.out.println(instance);
			System.out.println("------------------------");
			
			double[] probaJ48 = cModelJ48.distributionForInstance(instanceJ48);
			
			for (double d : probaJ48) {
				System.out.print(d + ",");
			}
			
			
			System.out.println("\n-------------------");
			
			ResultWindow resultWindow = new ResultWindow(precision * 100, precisionJ48 * 100);
		} catch (Exception e1) {
			e1.printStackTrace();
		}
	}
}
